package com.woniuxy.his.service.impl;

import com.woniuxy.his.common.CommonUtils;
import com.woniuxy.his.entity.User;
import com.woniuxy.his.mapper.UserMapper;
import com.woniuxy.his.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

@Service
@Slf4j
public class UserServiceImpl implements IUserService {

    @Resource
    private UserMapper userMapper;
    @Override
    public Integer addUser(String username, String password) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        System.out.println("userservice业务层添加用户"+username+":"+password);
        User user = new User();
        String md5 = CommonUtils.md5(password);
        System.out.println("加密后为"+md5);
        user.setUsername(username);
        user.setPassword(md5);
        int insert = userMapper.addUser(user);
        return insert;
    }
}
